import { getInfo } from '@api/user'
import { useUserStore } from '@stores/useUserStore'
import router from '@router'
// let userStore = useUserStore()

const useLogin = async (token: string) => {
  if (token) {
    // localStorage.setItem('token', token) // 存储token
    await useUserStore().isLogin(token)
    let res = await getInfo() // 获取用户信息
    useUserStore().setUserInfo(res.data) // 保存用户信息到store
    router.app.config.globalProperties.$hideLoginDialog() // 关闭dialog
  }
  return
}
export default useLogin